package com.jt.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//指定配置文件进行加载
@PropertySource("classpath:/properties/redis.properties")
public class RedisController {
   /* private String host="127.12.45.250";
    private int pot=697;*/

    //通过yml赋值
   @Value("${redis.host}")
    private String host;
    @Value("${redis.port}")
    private int port;

    //通过properties赋值
    @Value("${redis2.host}")
    private String host2;
    @Value("${redis2.port}")
    private int port2;

    @RequestMapping("/getNode")
    public String getNod(){
        return "YML赋值："+host+" ; "+port+
                "pro赋值："+host2+" ;"+port2;
    }

}
